package com.ruoyi.web.controller.diary;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.MorningDiaryInfo;
import com.ruoyi.system.service.IMorningDiaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description: 晨间日记
 * @Author: Burt [Shitian.Wen@desay-svautomotive.com] on [2022年03月03日 13:26:10]
 * @Modified By: [修改人] on [修改日期] for [修改说明]
 */
@Api("MorningDiary")
@Controller
@RequestMapping("/electron/diary/morning_diary")
public class MyMorningDiaryController extends BaseController {
    @Autowired
    private IMorningDiaryService morningDiaryService;

    /**
     * 获取返回内容
     */
    @ApiOperation("获取晨间日记列表")
    @GetMapping("/getMorningDiary")
    @ResponseBody
    public AjaxResult getMorningDiary(String userId) {
        if (ObjectUtil.isNull(userId)) {
            return error("userId不能为空");
        }
        return AjaxResult.success();
    }

    /**
     * 获取返回内容
     */
    @ApiOperation("保存晨间日记")
    @PostMapping("/saveMorningDiary")
    @ResponseBody
    public AjaxResult saveMorningDiary(MorningDiaryInfo morningDiaryInfo) {
        if (ObjectUtil.isNull(morningDiaryInfo.getUserId())) {
            return error("不能为空");
        }
        morningDiaryService.insertMorningDiaryInfo(morningDiaryInfo);
        return AjaxResult.success();
    }
}
